from rest_framework import serializers
from dvadmin.utils.serializers import CustomModelSerializer
from .models import Supplier, SupplierEvaluation, SupplierProduct

class SupplierSerializer(CustomModelSerializer):
    """供应商信息序列化器"""
    
    class Meta:
        model = Supplier
        fields = "__all__"
        read_only_fields = ["id"]

class SupplierCreateUpdateSerializer(CustomModelSerializer):
    """供应商信息创建/更新序列化器"""

    class Meta:
        model = Supplier
        fields = "__all__"

class SupplierEvaluationSerializer(CustomModelSerializer):
    """供应商评估序列化器"""
    supplier_name = serializers.CharField(source='supplier.name', read_only=True)
    
    class Meta:
        model = SupplierEvaluation
        fields = "__all__"
        read_only_fields = ["id"]

class SupplierEvaluationCreateUpdateSerializer(CustomModelSerializer):
    """供应商评估创建/更新序列化器"""

    class Meta:
        model = SupplierEvaluation
        fields = "__all__"

class SupplierProductSerializer(CustomModelSerializer):
    """供应商产品序列化器"""
    supplier_name = serializers.CharField(source='supplier.name', read_only=True)
    
    class Meta:
        model = SupplierProduct
        fields = "__all__"
        read_only_fields = ["id"]

class SupplierProductCreateUpdateSerializer(CustomModelSerializer):
    """供应商产品创建/更新序列化器"""

    class Meta:
        model = SupplierProduct
        fields = "__all__" 